/**
 * 
 */
package com.gsit.expenditure.controller;

import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.MenuBar;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

import com.gsit.expenditure.client.domina.CustomerBean;
import com.gsit.expenditure.client.domina.FXMLBase;
import com.gsit.expenditure.utils.Page;
import com.gsit.expenditure.utils.ViewHandler;

/**
 * @author udichee
 * 
 */
public class MainAppController implements Initializable {
	
	
	@FXML
	private static StackPane centerPane;
	@FXML
	private MenuBar menuBar;

	@Override
	public void initialize(URL arg0, ResourceBundle arg1) {
		HBox.setHgrow(menuBar, Priority.ALWAYS);

	}
	

	@FXML
	public void createNewCustomer() {
		centerPane.getChildren().clear();

		centerPane.getChildren().add(ViewHandler.loadPage(Page.CREATE_CUSTOMER));

	}

	@FXML
	public void searchCustomer() {
		
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.SEARCH_CUSTOMER));

	}
	
	@FXML
	public void createInvoice() {
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.CREATE_INVOICES));
	}

	@FXML
	public void searchInvoice(){
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.SEARCH_INVOICES));
		
	}
	
	@FXML
	public void createNewVendor(){
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.CREATE_VENDOR));
		
	}
	
	@FXML
	public void createVechile(){
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.CREATE_VECHILE));
		
	}
	@FXML
	public void searchVendor(){
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.SEARCH_VENDOR));
		
	}
	@FXML
	public void aboutUs() {
		//centerPane.getChildren().clear();
		FXMLBase fxmlBase =  ViewHandler.createFXMLBase(Page.ABOUT_US);
		fxmlBase = ViewHandler.createDialog(fxmlBase, "Welcome to GSIT......");
		fxmlBase.getDialogStage().showAndWait();
		
	}
	
	@FXML
	public void createBill() {
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.TRAVEL_BILL));
	}
	
	@FXML
	public void otherBill() {
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(Page.OTHER_BILL));
	}
	
	
	/*public static StackPane getCenterPane(){
		return  centerPane;
	}*/

	public static void loadNext(Page page){
		centerPane.getChildren().clear();
		centerPane.getChildren().add(ViewHandler.loadPage(page));
	}
}
